<?php
/**
 * Created by PhpStorm.
 * User: wangjie
 * Date: 2021/01/22
 * Time: 17:49
 */

namespace App\Api\Controllers\YSEPay;


use App\Api\Controllers\BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class OauthController extends BaseController
{
    public function payView(Request $request)
    {
        $data = json_decode(base64_decode((string)$request->get('data')), true);
        $merchantNo = DB::table('ysepay_stores')->where('store_id', $data['store_id'])->value('merc_id');
        if (!$merchantNo) {
            $merchantNo = DB::table('ysepay_stores', 'ysepay')
                ->join('stores as store', 'ysepay.store_id', 'store.store_id')
                ->where('store.id', $data['store_pid'])
                ->value('ysepay.merc_id');
        }
        $data = [
            'ways_type' => $data['ways_type'],
            'store_id' => $data['store_id'],
            'store_name' => $data['store_name'],
            'store_address' => '',
            'open_id' => '',
            'merchant_id' => $data['merchant_id'],
            'merchantNo' => $merchantNo,
        ];
        return view('ysepay.pay_view', compact('data'));
    }

}
